let age1= 18
let str ='acc'
let bool=true
let nu:null =null
let un:undefined = undefined
console.log(age1, str, bool, nu,un)

//数组类型
let arr:number[]=[1,2,3]
let arr1:string[]=['1','1']
let  arr2:Array<number>=[1,2,3]
let  arr3:Array<string>=["1",'2','dd']
console.log(arr)
let arr4   = [1,'2',true]
console.log(arr2)

// 元组
let arr5:[number,string,boolean] =[14,'1',true]

// 联合类型
let age3 : (number | boolean)  = 10
age3=true
console.log(age3)
let arr6:(number|boolean)[] =[1,2,3,true]

//类型别名
type Arr=(number|boolean|string)[]
let arr7:Arr=[1,2,"3",true]
type Num= number|string
let num1:Num = 10

//函数类型 ：函数参数和返回值的类型
function fn(n:number):number{
    return Number('1')
}
fn(1)
var fn1 = function (){
    console.log(11)
}

// 对象类型
let obj={
    name:'aa',
    age:5,
    add:()=>{
        console.log(11)
    }
}

type  Person = {
    age:number
    name:string
    add:(n:number)=>void
}
let p :Person = {
    name:'1',
    age:10,
    add:(n:number)=>{
        console.log(11)
    }
}
p.add(2)
console.log(p)